<template>
    <div class="back">
        <el-form :label-position="labelPosition" label-width="80px" :model="formLabelAlign" style="width:60%;margin-left:20px;">
            <div class="baseinfo">
                <h1><label class="num">1. </label>职位基本信息</h1>
                <el-row>
                    <el-col :span="11">
                        <el-form-item label="公司">
                            <el-input v-model="formLabelAlign.name" placeholder="请输入公司名称"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="2">&nbsp;</el-col>
                    <el-col :span="11">
                    <el-form-item label="招聘类型">
                        <el-select v-model="formLabelAlign.recruitType" placeholder="请选择招聘类型" style="width:100%">
                            <el-option label="企业招聘" value="企业招聘"></el-option>
                            <el-option label="个人招聘" value="个人招聘"></el-option>
                            <el-option label="政治招聘" value="政治招聘"></el-option>
                            <el-option label="军事招聘" value="军事招聘"></el-option>
                            <el-option label="经济招聘" value="经济招聘"></el-option>
                            <el-option label="文化招聘" value="文化招聘"></el-option>
                        </el-select>
                    </el-form-item>
                    </el-col>
                </el-row>
                
                
                <el-form-item label="职位名称">
                    <el-input v-model="formLabelAlign.position" placeholder="请输入职位名称"></el-input>
                </el-form-item>
                <el-form-item label="工作地点">
                    <el-input v-model="formLabelAlign.place" placeholder="请输入具体的工作地点"></el-input>
                </el-form-item>
                <el-form-item label="工作城市">
                     <linkage 
                    v-on:listenProvince="showProvince"
                    v-on:listenCity="showCity"
                    v-on:listenRegion="showRegion">
                    </linkage>
                </el-form-item>
            </div>
            <div class="require">
                <h1><label class="num">2. </label>职位要求</h1>
                <!-- <label>我们将通过一下条件，为您精确推荐适合的牛人，请尽量详细的填写</label> -->
                <el-row>
                    <el-col :span="11">
                        <el-form-item label="经验">
                            <el-select v-model="formLabelAlign.experience" placeholder="请选择经验" style="width:100%">
                                <el-option label="在校生" value="在校生"></el-option>
                                <el-option label="应届生" value="应届生"></el-option>
                                <el-option label="3~5年" value="3~5年"></el-option>
                                <el-option label="5年以上" value="5年以上"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="2">&nbsp;</el-col>
                    <el-col :span="11">    
                        <el-form-item label="学历">
                            <el-select v-model="formLabelAlign.education" placeholder="请选择学历" style="width:100%">
                                <el-option label="无" value="无"></el-option>
                                <el-option label="中专" value="中专"></el-option>
                                <el-option label="大专" value="大专"></el-option>
                                <el-option label="本科" value="本科"></el-option>
                                <el-option label="研究生" value="研究生"></el-option>
                                <el-option label="博士" value="博士"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row>
                    <el-col :span="11">
                        <el-form-item label="薪资范围">
                            <el-select v-model="formLabelAlign.salary" placeholder="请选择薪资范围" style="width:100%">
                                <el-option label="3k~5k" value="3k~5k"></el-option>
                                <el-option label="5k~7k" value="5k~7k"></el-option>
                                <el-option label="7k~10k" value="7k~10k"></el-option>
                                <el-option label="10k~15k" value="10k~15k"></el-option>
                            </el-select>
                         </el-form-item>
                    </el-col>
                    <el-col :span="2">&nbsp;</el-col>
                    <el-col :span="11">    
                        <el-form-item label="职位类型">
                            <el-select v-model="formLabelAlign.positionType" placeholder="请选择职位类型" style="width:100%">
                                <el-option label="管理类" value="管理类"></el-option>
                                <el-option label="专业技术类" value="专业技术类"></el-option>
                                <el-option label="专业支持类" value="专业支持类"></el-option>
                                <el-option label="营销类" value="营销类"></el-option>
                                <el-option label="操作类" value="操作类"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>

                
                
                <el-form-item label="职位描述" prop="desc">
                    <el-input type="textarea" v-model="formLabelAlign.jobDescription" placeholder="不多于50字"></el-input>
                </el-form-item>
                <el-form-item label="关键词" class="aaa">
                    <el-input v-model="formLabelAlign.jobsepecial" placeholder="请输入职位关键词"></el-input>
                </el-form-item>
                <el-button type="primary" @click="onSubmit()" class="submit">提交</el-button>
            </div>
        </el-form>
    </div>
</template>

<script>
import linkage from '@/components/linkage'
export default {
    name:'publishRecruitment',
    components:{
        linkage
    },
    data(){
        return{
            labelPosition: 'left',
            formLabelAlign: {
                name: '',
                recruitType: '',
                position: '',
                province:'',
                city:'',
                region:'',
                place:'',
                education:'',
                experience:'',
                salary:'',
                positionType:'',
                jobDescription:'',
                jobsepecial:''
            }
        }
    },
    methods:{
        onSubmit(){
            console.log("——————————companyInfo——————————");
            var token = localStorage.getItem("token");
            console.log("Token内容",token);
            let formLabelAlign = this.formLabelAlign
            console.log(formLabelAlign);
            let name = formLabelAlign.name;
            let recruitType = formLabelAlign.recruitType;
            let position = formLabelAlign.position;
            let province = formLabelAlign.province;
            let city = formLabelAlign.city;
            let region = formLabelAlign.region;
            let experience = formLabelAlign.experience;
            let education = formLabelAlign.education;
            let salary = formLabelAlign.salary;
            let jobDescription = formLabelAlign.jobDescription;
            let positionType = formLabelAlign.positionType;
            let jobsepecial = formLabelAlign.jobsepecial;
            let place = formLabelAlign.place;
            if(name&&recruitType&&position&&province&&city&&region&&experience&&education&&salary&&positionType&&place){
              depot.post({
                url: 'empservice/recruitment/publish',
                data:{
                    'companyname':name,
                    'emptype':recruitType,
                    'job':position,
                    'province':province,
                    'city':city,
                    'region':region,
                    'jobexp':experience,
                    'education':education,
                    'salary':salary,
                    'jobdescription':jobDescription,
                    'jobtype':positionType,
                    'jobsepecial':jobsepecial,
                    'address':place
                },
                cb: (res)=> {
                    console.log("!!!!!",res);
                     if(res.code == 20000){
                     alert("发布成功!");
                     this.$router.push("./existingRecruitment")
                     }else if(res.code==20001){
                        alert("请先登录再进行下一步操作!");
                    }
                }
                })
            }else{
                alert("请填写完整！")
            }
        },
         //组件传值（子传父）
        showProvince(data){
          this.formLabelAlign.province = data;
          console.log("工作省份：",this.formLabelAlign.province);
        },
        showCity(data){
            this.formLabelAlign.city = data;
            console.log("工作城市：",this.formLabelAlign.city);
        },
        showRegion(data){
            this.formLabelAlign.region =data;
            console.log("工作县区：",this.formLabelAlign.region);
        },
    }
}
</script>

<style lang="less" scoped>
.num{
    color: #18a3b1;
    font-size: 30px;
}
// .baseinfo .el-input{
    // width: 30%;
// }
// .aaa{
//     width: 23.7%;
// }
// .require .el-input{
//     width: 120%;
// }
.el-form h1{
    color: rgb(0, 0, 0);
    font-size: 24px;
    text-align: left;
}
// .el-form{
    // margin-left: 50px;
// }
.submit{
    float: right;
}
</style>
<style lang="less">
  .el-form-item__label{
    color: rgb(78, 77, 77);
    font-weight: 600;
}  
</style>